<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
    <style>
        div>div {
            width: 60px;
            height: 60px;
            border: 2px solid #bbb;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
            margin: 10px;
            float: left;
        }
    </style>
</head>

<body>
    <div id="app">
        <div v-bind:style="{'border-color':selected}">1</div>
        <!-- 驼峰命名法 -->
        <div v-bind:style="{'borderColor':selected}">2</div>
        <div :style="{'background':active}">3</div>
        <div :style="div1">4</div>
        <!-- 计算属性 -->
        <div :style="ss">4</div>
        <!-- 方法 -->
        <div :style="ff1()">4</div>

        <!-- 通过数组方法绑定style -->
        <div :style="[div1,ss]">4</div>
        <div :style="[{borderColor:'#000'},ss]">5</div>
        <div :style="{borderColor:selected1?'#000':'#bbb'}">44</div>




    </div>
    <script>
        Vue.createApp({
            data() {
                return {
                    selected:"#000",
                    selected1:false,
                    active:"#bbb",
                    div1:{background:"#555",borderColor:"#bbb"}
                }
            },
            // 绑定计算属性和方法
            methods: {
                ff1(){
                    return this.div1
                }
            },
            computed:{
                ss(){
                     return this.div1
                }
            }
        }).mount('#app')
    </script>
</body>

</html>